package com.qf.courtesycard.mqcustomer.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 刘欣
 * @createTime 2023/3/11 10:16
 * @description
 */
@Configuration
public class RabbitConfig {

    @Bean
    public FanoutExchange fanoutExchange() {
        FanoutExchange fanoutExchange = new FanoutExchange("ticket_exchange", true, false);
        return fanoutExchange;
    }

    @Bean("queueTicketDB")
    public Queue queueTicketDB() {
        Queue queue = new Queue("queue_ticketDB_logs");
        return queue;
    }

    @Bean("queueTikcketEs")
    public Queue queueTikcketEs() {
        Queue queue = new Queue("queue_ticketEs_logs");
        return queue;
    }

    @Bean
    public Binding bindingQueueTicketDB(FanoutExchange fanoutExchange, Queue queueTicketDB) {
        return BindingBuilder.bind(queueTicketDB).to(fanoutExchange);
    }

    @Bean
    public Binding bindingQueueTikcketEs(FanoutExchange fanoutExchange, Queue queueTikcketEs) {
        return BindingBuilder.bind(queueTikcketEs).to(fanoutExchange);
    }
}
